#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N = 2e5;
#define INF 0x7fffffff
typedef long long int ll;
using namespace std;
//----------------------------------------------------------------------------//
int st[10];
set<int, greater<int>> cnt;
void solve()
{
    int num[11] = { 0,1,2,3,4,5,6,7,8,9 };
    do
    {
        for (int i = 1; i <= 8; i++)
        {
            memset(st, 0, sizeof st);
            ll a = 0, b = 0;
            for (int j = 1; j <= i; j++)
            {
                a *= 10; a += num[j];
            }
            for (int j = i + 1; j <= 9; j++)
            {
                b *= 10; b += num[j];
            }
            ll ans = a * b;
            ll res = ans;
            bool ok = true;
            while (ans)
            {
                st[ans % 10]++;ans /= 10;
            }
            for (int j = 1; j <= 9; j++)
            {
                if (st[j] != 1)
                {
                    ok = false; break;
                }
            }
            if (ok) cnt.insert(res);
        }
    } while (next_permutation(num + 1, num + 10));
    pld((*cnt.begin()));
    puts("");
}

int main()
{
    int T=1;
    //sd(T);
    while (T--)
    {
        solve();
    }
    return 0;
}